package com.balance.anole.business.to;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Set;

import com.balance.anole.admin.to.AgentTO;
import com.balance.anole.admin.to.StaffInfoTO;
import com.balance.anole.admin.to.WarehouseTO;
import com.balance.anole.common.to.AnoleBaseTO;
import com.balance.anole.common.to.CodeLookTO;

public class OrderTO extends AnoleBaseTO {

	private static final long serialVersionUID = -6833631227428792128L;
	
	public static final String ORDER_WORK_DRAFT = "D";
	public static final String ORDER_WORK_SUMBIT = "S";
	public static final String ORDER_WORK_CONFIRM = "C";
	public static final String ORDER_WORK_GOODS = "A";
	public static final String ORDER_WORK_DELIVER = "V";
	public static final String ORDER_WORK_FINAL = "F";
	
	private String txnId;  //订单编号
	private Date txnTms;   //订单日期
	private CodeLookTO txnStatus; //订单状态
	private CodeLookTO orderProperty;  //订单属性	
	private CodeLookTO orderType;   //订货类别
	private CodeLookTO seasonType;      //季节类别
	private CodeLookTO manufactureMode;  //加工方式
	private Set<OrderProductItemTO> orderPdtItemList;    //所定商品列表
	private Set<OrderStateChangeLogTO> changeLog;    //状态修改记录
	private WarehouseTO sourceWarehouse;   //订货方仓库信息
	private StaffInfoTO sourceStaffTO;  //订货方联系人
	private AgentTO sourceAgent;
	private AgentTO targetAgent;
	private WarehouseTO targetWarehouse;   //配货方仓库信息
	private StaffInfoTO targetStaffTO;  //配货方联系人
	private String expressCompName; //快递公司
	private String destinationAddr; //目的地地址
	private String zipCode;         //邮政编码
	private Date expectedRecvDt;    //期望到货日期
	private Date expiringDt;        //最后到货日期
	private Date recvDt;            //实际到货日期
	private Date delivDt;           //发货日期

	private TransactionTO transactionTO = new TransactionTO();

	public TransactionTO getTransactionTO() {
		return transactionTO;
	}
	public void setTransactionTO(TransactionTO transactionTO) {
		this.transactionTO = transactionTO;
	}
	public String getTxnId() {
		return txnId;
	}
	public void setTxnId(String txnId) {
		this.txnId = txnId;
	}	
	public Date getTxnTms() {
		return txnTms;
	}
	public void setTxnTms(Date txnTms) {
		this.txnTms = txnTms;
	}	
	public CodeLookTO getOrderProperty() {
		return orderProperty;
	}
	public void setOrderProperty(CodeLookTO orderProperty) {
		this.orderProperty = orderProperty;
	}
	public CodeLookTO getOrderType() {
		return orderType;
	}
	public void setOrderType(CodeLookTO orderType) {
		this.orderType = orderType;
	}
	public CodeLookTO getSeasonType() {
		return seasonType;
	}
	public void setSeasonType(CodeLookTO seasonType) {
		this.seasonType = seasonType;
	}	
	public CodeLookTO getManufactureMode() {
		return manufactureMode;
	}
	public void setManufactureMode(CodeLookTO manufactureMode) {
		this.manufactureMode = manufactureMode;
	}
	public WarehouseTO getSourceWarehouse() {
		return sourceWarehouse;
	}
	public void setSourceWarehouse(WarehouseTO sourceWarehouse) {
		this.sourceWarehouse = sourceWarehouse;
	}
	public WarehouseTO getTargetWarehouse() {
		return targetWarehouse;
	}
	public void setTargetWarehouse(WarehouseTO targetWarehouse) {
		this.targetWarehouse = targetWarehouse;
	}
	public Set<OrderProductItemTO> getOrderPdtItemList() {
		return orderPdtItemList;
	}
	public void setOrderPdtItemList(Set<OrderProductItemTO> orderPdtItemList) {
		this.orderPdtItemList = orderPdtItemList;
	}
	public CodeLookTO getTxnStatus() {
		return txnStatus;
	}
	public void setTxnStatus(CodeLookTO txnStatus) {
		this.txnStatus = txnStatus;
	}
	public String getExpressCompName() {
		return expressCompName;
	}
	public void setExpressCompName(String expressCompName) {
		this.expressCompName = expressCompName;
	}
	public StaffInfoTO getSourceStaffTO() {
		return sourceStaffTO;
	}
	public void setSourceStaffTO(StaffInfoTO sourceStaffTO) {
		this.sourceStaffTO = sourceStaffTO;
	}
	public StaffInfoTO getTargetStaffTO() {
		return targetStaffTO;
	}
	public void setTargetStaffTO(StaffInfoTO targetStaffTO) {
		this.targetStaffTO = targetStaffTO;
	}
	public String getDestinationAddr() {
		return destinationAddr;
	}
	public void setDestinationAddr(String destinationAddr) {
		this.destinationAddr = destinationAddr;
	}
	public String getZipCode() {
		return zipCode;
	}
	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}
	public Date getExpectedRecvDt() {
		return expectedRecvDt;
	}
	public void setExpectedRecvDt(Date expectedRecvDt) {
		this.expectedRecvDt = expectedRecvDt;
	}
	public Date getExpiringDt() {
		return expiringDt;
	}
	public void setExpiringDt(Date expiringDt) {
		this.expiringDt = expiringDt;
	}
	public Date getRecvDt() {
		return recvDt;
	}
	public void setRecvDt(Date recvDt) {
		this.recvDt = recvDt;
	}
	public Date getDelivDt() {
		return delivDt;
	}
	public void setDelivDt(Date delivDt) {
		this.delivDt = delivDt;
	}
	public AgentTO getSourceAgent() {
		return sourceAgent;
	}
	public void setSourceAgent(AgentTO sourceAgent) {
		this.sourceAgent = sourceAgent;
	}
	public AgentTO getTargetAgent() {
		return targetAgent;
	}
	public void setTargetAgent(AgentTO targetAgent) {
		this.targetAgent = targetAgent;
	}
	public Set<OrderStateChangeLogTO> getChangeLog() {
		return changeLog;
	}
	public void setChangeLog(Set<OrderStateChangeLogTO> changeLog) {
		this.changeLog = changeLog;
	}	
	
	public List<OrderStateChangeLogTO> getChangeLogSortedList(){
		List<OrderStateChangeLogTO> result = changeLog == null ? null : new ArrayList<OrderStateChangeLogTO>(changeLog);
		Collections.sort(result, new Comparator<OrderStateChangeLogTO>(){

			@Override
			public int compare(OrderStateChangeLogTO arg0,
					OrderStateChangeLogTO arg1) {
				return arg1.getUpdateDt().compareTo(arg0.getUpdateDt());
			}
			
		});
		return result;
	}
	
}
